<%@page import="model.Myuser"%>
<%@ page import="java.util.List"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="main.css">
<title>Admin set editor</title>
</head>
<body>

<%

List<Myuser> userlist = (List<Myuser>)request.getAttribute("userlist");
List<Myuser> userlist_e = (List<Myuser>)request.getAttribute("userlist_e");
List<Myuser> userlist_m = (List<Myuser>)request.getAttribute("userlist_m");
List<Myuser> userlist_a = (List<Myuser>)request.getAttribute("userlist_a");

String username = (String) session.getAttribute("username");


if(username==null){
    out.print("Please login first! redirecting to Login...");
    response.setHeader("Refresh","1;URL=login.jsp");
}
else{
	out.print("Hello, " + username);
}
%>

<center>
<h2>Admin set editors</h2><br>

<h3></h3>
<table  border="1" width="900">
<%
	if(userlist!=null){
%>
		<tr>
			<td><b>Username</b></td>
			<td><b>User ID</b></td>
			<td><b>Authority</b></td>
			<td></td></tr>
<% 
		for (Myuser u: userlist){
%>
			<tr><td> <%=u.getUsername()%> </td>
				<td> <%=u.getUserid()%> </td>
				<td> <%=u.getAuthority()%> </td>
				<td>									
					<input type="button" name="approve" id="approve_btn" value="Set Editor" onclick="javascript:location.href='AdminServlet?userid=<%=u.getUserid()%>'"/>
					<input type="button" name="delete" id="delete" value="Delete Account" onclick="javascript:location.href='AdminServlet?duserid=<%=u.getUserid()%>'"/>
					
				</td></tr>
<%
		}
	}
%>
</table>

<br><br>

<table  border="1" width="900">
<%
	if(userlist!=null){
%>
		<tr>
			<td><b>Username</b></td>
			<td><b>User ID</b></td>
			<td><b>Authority</b></td>
			<td></td></tr>
<% 
		for (Myuser u: userlist_e){
%>
			<tr><td> <%=u.getUsername()%> </td>
				<td> <%=u.getUserid()%> </td>
				<td> <%=u.getAuthority()%> </td>
				<td>									
					<input type="button" name="approve" id="approve_btn" value="Set Editor" onclick="javascript:location.href='AdminServlet?userid=<%=u.getUserid()%>'"/>
					<input type="button" name="delete" id="delete" value="Delete Account" onclick="javascript:location.href='AdminServlet?duserid=<%=u.getUserid()%>'"/>
					
				</td></tr>
<%
		}
	}
%>
</table>

<br><br>

<table  border="1" width="900">
<%
	if(userlist!=null){
%>
		<tr>
			<td><b>Username</b></td>
			<td><b>User ID</b></td>
			<td><b>Authority</b></td>
			<td></td></tr>
<% 
		for (Myuser u: userlist_m){
%>
			<tr><td> <%=u.getUsername()%> </td>
				<td> <%=u.getUserid()%> </td>
				<td> <%=u.getAuthority()%> </td>
				<td>									
					<input type="button" name="approve" id="approve_btn" value="Set Editor" onclick="javascript:location.href='AdminServlet?userid=<%=u.getUserid()%>'"/>
					<input type="button" name="delete" id="delete" value="Delete Account" onclick="javascript:location.href='AdminServlet?duserid=<%=u.getUserid()%>'"/>
				</td></tr>
<%
		}
	}
%>
</table>

<br><br>

<table  border="1" width="900">
<%
	if(userlist!=null){
%>
		<tr>
			<td><b>Username</b></td>
			<td><b>User ID</b></td>
			<td><b>Authority</b></td>
			<td></td></tr>
<% 
		for (Myuser u: userlist_a){
%>
			<tr><td> <%=u.getUsername()%> </td>
				<td> <%=u.getUserid()%> </td>
				<td> <%=u.getAuthority()%> </td>
				<td>									
					<input type="button" name="approve" id="approve_btn" value="Set Editor" onclick="javascript:location.href='AdminServlet?userid=<%=u.getUserid()%>'"/>
					<input type="button" name="delete" id="delete" value="Delete Account" onclick="javascript:location.href='AdminServlet?duserid=<%=u.getUserid()%>'"/>
				</td></tr>
<%
		}
	}
%>
</table>



<br>
<td> <input type="button" name="return" id="return" value="Go back" onclick="javascript:location.href='Home'"/> </td>

</center>



</body>
</html>